<template>
	<view class="con">
		<image mode="widthFix" :src="img"></image>
	</view>
</template>
<script>
	let app = getApp();
	import {
		login,
		hello
	} from '@/api/public.js';
	export default {
		name: "Login",
		data: function() {
			return {
				img:''
			};
		},
		mounted: function() {
			
		},
		onLoad(options) {
			let self = this
			// hello({
				
			// }).then(res => {
			// 	if (res.data) {
			// 		self.img = res.data.helloImgUrl
			// 	}
			// });
			if (options.hasOwnProperty('id') || options.scene) {
				var value = this.$util.getUrlParams(decodeURIComponent(options.scene));
				console.log(value)
				app.globalData.spread = value.sd ? value.sd : '';
				app.globalData.id = value.id ? value.id : '';
				app.globalData.marketingType = value.mt ? value.mt : '0';
			}
		},
		onShow() {
			let self = this;
			setTimeout(function(){ 
				if (__wxConfig.envVersion === 'release') {
					uni.login({
						success(res) {
							login({
								code: res.code,
								type: 'routine'
							}).then(res => {
								if (res.data) {
									if(res.data.phone == null || !res.data.phone){
										uni.reLaunch({
											url:'/pages/users/wechat_login/index'
										})
										return false;
									}else if(res.data.isPromoter == null || !res.data.isPromoter){
										uni.reLaunch({
											url:'/pages/activity/vip_paid/index' 
										})
									}else{
										self.$store.commit('LOGIN', {
											token: res.data.token
										});
										self.$store.commit("SETUID", res.data.id);
										self.$store.commit("SetMerchantEmployeeList", {
										  'merchantEmployeeList': res.data.merchantEmployeeList
										});
										uni.switchTab({
											url:'/pages/index/index'
										})
									}
								}else{
									uni.switchTab({
										url:'/pages/index/index'
									})
								}
							});
						},
						fail(){
							uni.switchTab({
								url:'/pages/index/index'
							})
						}
					})
				} else {
					uni.switchTab({
						url:'/pages/index/index'
					})
				}
			}, 1000); 
		},
		methods: {
			
		}
	};
</script>
<style lang="scss" scoped>
	.con{
		width: 100vw;
		height: 100vh;
		background-color: #fff !important;
		image{
			width: 100%;
		}
	}
</style>